<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
cfc('core')->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
if($_RQ['op']=='main'){
    $member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
	if(!member){
		exi('找不到会员信息！','error');
	}
	$user_id=pdo_getcolumn('jy_meiye_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'id');
	if(!$user_id){
		$insert=array(
			'id'=>$_SESSION['uid'],
			'uniacid'=>$_SESSION['uniacid'],
			'mobile'=>$member['mobile'],
			'name'=>$member['realname'],
			'headimg'=>$member['avatar'],
			'sex'=>$member['sex'],
		);
		pdo_insert('jy_meiye_user',$insert);
	}
	$user=pdo_get('jy_meiye_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['member']=$member;
	$return['user']=$user;
	exi($return);
}
//修改用户信息
if($_RQ['op']=='set'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$data=array(
				'name'=>$postdata['name'],
				'mobile'=>$postdata['mobile'],
				'headimg'=>$postdata['headimg'],
				);
		$user_id=pdo_getcolumn('jy_meiye_user',array('id'=>$_SESSION['uid']),'id');		
		if($user_id){
			pdo_update('jy_meiye_user',$data,array('id'=>$_SESSION['uid']));
			exi('修改成功','','jy_meiye/home/');		 
		}
	}
	$user=pdo_get('jy_meiye_user',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$return['item']=$user;
	$return['member']=$member;
	exi($return);
	}
